using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using FiltronASP.Modules.Abstracts;
using FiltronASP.Models.DAO.Interfaces;
using System.Web.UI.WebControls;
using FiltronASP.Models;
using FiltronASP.Models.DAO.Filtron;
using FiltronASP.Models.DAO.Interfaces.Filtron;
using FiltronASP.Helpers.CatalogueMenu;
using FiltronASP.Helpers.Translations;

namespace FiltronASP.Modules
{
    public class lpgCarsSearchModule : AbstractModule
    {
        private Page currentPage;

        /// <summary>
        /// Klasa odpowiedzialna za generowanie contentu przez modul.
        /// </summary>
        /// <param name="page">biezaca strona</param>
        /// <returns>content</returns>
        public override string GenerateContent(FiltronASP.Models.Page page)
        {
            this.currentPage = page;
            int pageId = page.page_id;
            int languageId = Convert.ToInt32(page.language_id);
            return this.generateBottomMenu(languageId, pageId) + this.generateInnerContent(languageId);
        }

        private string generateBottomMenu(int languageId, int pageId) 
        {
           string htmlToReturn = "";
           /* htmlToReturn += "<div id=\"bottomMenu\">";
            htmlToReturn += "   <div class=\"selectMarketMenu\">";
            htmlToReturn += "       <span class=\"changeMarketInfo\">" + translationHelper.getTranslation("_currentMarketInfoFiltron", languageId) + "</span>";
            htmlToReturn += "       <a href=\"" + translationHelper.getTranslation("_changeMarketLink", languageId) + "\" class=\"changeMarketButton\">" + translationHelper.getTranslation("_changeMarket", languageId) + "</a>";
            htmlToReturn += "   </div>";
            htmlToReturn += "   <ul class=\"selectCarTypeMenu\">";

            
            htmlToReturn += CatalogueMenuHelper.generateMenuFiltron(languageId, pageId);

            htmlToReturn += "   </ul>"; //</selectCarTypeMenu>
            
            htmlToReturn += "<div id=\"selectCarTypeMenuUnder\">";
            htmlToReturn += CatalogueMenuHelper.GenerateLastModifiedWix(this.currentPage.language_id);
            htmlToReturn += "</div>"; //</selectCarTypeMenuUnder>
            htmlToReturn += "</div>"; //</bottomMenu>    */        
            return htmlToReturn;
        }

        private string generateInnerContent(int languageId) {
            string htmlToReturn = "";
               
            htmlToReturn += this.generateEnginePart(languageId);
            return htmlToReturn;
        }

        private string generateEnginePart(int languageId) {
            string htmlToReturn = "";
           // htmlToReturn += "<div id=\"searchLeftSide\" style=\"display: block !important;\">";

           // htmlToReturn += "<h3>" + translationHelper.getTranslation("_selectLPG", languageId) + "</h3>";
          //  htmlToReturn += "<table id=\"specialFilterTable\">";
            /* htmlToReturn += "<thead><tr><td class=\"engine\">" + translationHelper.getTranslation("_filter", languageId) + "</td><td class=\"gs\">" + translationHelper.getTranslation("_gas", languageId) + "</td></tr></thead>";
            htmlToReturn += "<tbody>";*/
            //headtable
            htmlToReturn += " <div class=\"col-lg-4 col-md-6 col-sm-6 col-xs-12 no-padding filters-resp-padding\">";
            htmlToReturn += "<div class=\"col-xs-12 no-padding overlay-engine overlay-engine-boder-b\">";
            htmlToReturn += "<div class=\"col-xs-12 no-padding\">";
            htmlToReturn += "<div class=\"col-xs-5 no-padding overlay-engine-boder-r\">";
            htmlToReturn += "<p>" + translationHelper.getTranslation("_filter", languageId) + "</p>";
            htmlToReturn += "</div>";
            htmlToReturn += "<div class=\"col-xs-7 no-padding \">";
            htmlToReturn += "<p class=\" lpg-p\">"+ translationHelper.getTranslation("_gas", languageId) +"</p>";
            htmlToReturn += " </div> </div> </div>";
        
            
            IFiltronSpecialFiltersDAO FiltronSpecialFiltersDAO = new FiltronSpecialFiltersDAO();
            IQueryable<filtron_special_filter> specialCollection = FiltronSpecialFiltersDAO.FindAll();
            foreach (filtron_special_filter special in specialCollection)
            {
                IFiltronFilterDAO filtronFilterDAO = new FiltronFilterDAO();
                FiltronFilter filterSingle = filtronFilterDAO.FindByPK(special.filter_id);
/*
                htmlToReturn += "<tr id=\"specialSelect-"+special.filter_id+"\" onclick=\"specialTrActive(this, "+special.filter_id+")\" class=\"\">";
                htmlToReturn += "<td id=\"" + filterSingle.filter_id + "\" onclick=\"makeFilterActive(this, '" + Helpers.XmlHelper.XMLHelper.getLanguageNameById(languageId) + "')\">" + filterSingle.filter_wix_number + "</td>";
                htmlToReturn += "<td>" + special.special_filter_installation + "</td>";
                htmlToReturn += "</tr>";
*/
                htmlToReturn += "  <div id=\"" + special.filter_id + "\" class=\"col-xs-12 no-padding overlay-engine engine-hover overlay-engine-boder-b makeFilterActive\" data-filter=\""+special.filter_id + "\" >";
                htmlToReturn += " <div class=\"col-xs-12 no-padding\">";    
                htmlToReturn += "<div class=\"col-xs-5 no-padding overlay-engine-boder-r\">";
                htmlToReturn += "<p class=\"engine-info-bold\">" + filterSingle.filter_wix_number + "</p>";
                htmlToReturn += "</div>";
                htmlToReturn += "<div class=\"col-xs-7 no-padding \">";

                htmlToReturn += "<p class=\"engine-info-normal lpg-p\">" + special.special_filter_installation + "</p>";
                htmlToReturn += " </div> </div> </div>";
        
            }
            
            htmlToReturn += "</div>";
            

            

            
            htmlToReturn += "<div class=\"col-lg-8 col-md-6 col-sm-6 col-xs-12 results-ajax filters-resp-padding searchRightSide\" id=\"filterDetails\">";
           
            /*htmlToReturn += "   <div class=\"searchRightSideTop\"></div>";
            htmlToReturn += "   <div id=\"searchRightSideBottom\"></div>";*/
            
            htmlToReturn += "</div>";
          
            return htmlToReturn;
        }
    }
}
